package com.droowa.model.dao;

import java.sql.SQLException;
import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.droowa.domain.ShopManager;

@Repository
public class ShopManagerDAOMybatisImpl implements ShopManagerDAO{
	
	@Autowired
	private SqlSessionTemplate session;

	@Override
	public int insertShopManager(ShopManager shopManager) throws SQLException {
		return session.insert(makeSqlId("insertShopManager"), shopManager);
	}

	@Override
	public int deleteShopManagerById(String shopManagerId) throws SQLException {
		return session.delete(makeSqlId("deleteShopManager"), shopManagerId);
	}

	@Override
	public int updateShopManager(ShopManager shopManager) throws SQLException {
		return session.update(makeSqlId("updateShopManager"), shopManager);
	}

	@Override
	public ShopManager selectShopManagerByShopManagerId(String shopManagerId)
			throws SQLException {
		System.out.println("운영자태이블DAO");
		return session.selectOne(makeSqlId("selectShopManagerByShopManagerId"), shopManagerId);
	}

	@Override
	public List<ShopManager> selectShopManagerByName(String name)
			throws SQLException {
		return session.selectList(makeSqlId("selectShopManagerByName"), name);
	}

	@Override
	public List<ShopManager> selectShopManagerByEmail(String email)
			throws SQLException {
		return session.selectList(makeSqlId("selectShopManagerByEmail"), email);
	}

	@Override
	public List<ShopManager> selectShopManagerBySort(String sort)
			throws SQLException {
		return session.selectList(makeSqlId("selectShopManagerBySort"), sort);
	}

	@Override
	public List<ShopManager> selectShopManager() throws SQLException {
		return session.selectList(makeSqlId("selectShopManager"));
	}

	private String makeSqlId(String id){
		return "droowa.shopManager."+id;
	}

}
